package init

import (
	"fmt"
	"github.com/elastic/go-elasticsearch/v7"
	"log"
	"service/basic/config"
)

func InitsEs() {
	var err error
	esCong := config.AppCong.ElasticSearch
	addr := fmt.Sprintf("%s:%d", esCong.Host, esCong.Port)
	cfg := elasticsearch.Config{
		Addresses: []string{
			addr,
		},
	}
	config.ES, err = elasticsearch.NewClient(cfg)
	if err != nil {
		panic(err)
	}
	log.Println("es init success")
}
